import { applyDecorators, createParamDecorator, ExecutionContext, UseGuards } from '@nestjs/common';

export const User = createParamDecorator(
  (data: unknown, ctx: ExecutionContext) => {
    console.log('自定义路由装饰器', data)
    const request = ctx.switchToHttp().getRequest();
    return request.user;
  },
);

export function Auth(...roles) { // 多个装饰器组合使用
  return applyDecorators(
    User,
    UseGuards()
  );
}